Commit 9720515b authored by Lucas Russo's avatar Lucas Russo

*Makefile: add more unified makefile

Added correct default targets in /usr/local
with headers in /usr/local/include, libraries in
/usr/local/lib, and binaries in /usr/local/bin
parent 9699d309
...@@ -14,7 +14,7 @@ MAKE = make ...@@ -14,7 +14,7 @@ MAKE = make
# Select board in which we will work. Options are: ml605, afc # Select board in which we will work. Options are: ml605, afc
BOARD = ml605 BOARD = ml605
INSTALL_DIR ?= /usr/lib INSTALL_DIR ?= /usr/local
export INSTALL_DIR export INSTALL_DIR
# Kernel stuff (pcie driver and library) relative # Kernel stuff (pcie driver and library) relative
...@@ -23,6 +23,9 @@ KERNEL_DIR = kernel ...@@ -23,6 +23,9 @@ KERNEL_DIR = kernel
KERNEL_VER = $(shell uname -r) KERNEL_VER = $(shell uname -r)
DRIVER_OBJ = /lib/modules/$(KERNEL_VER)/extra/pciDriver.ko DRIVER_OBJ = /lib/modules/$(KERNEL_VER)/extra/pciDriver.ko
# Client library
LIBCLIENT_DIR=libclient
# General C flags # General C flags
CFLAGS = -std=gnu99 -O2 -DWR_SHIFT=2 CFLAGS = -std=gnu99 -O2 -DWR_SHIFT=2
...@@ -79,15 +82,18 @@ OBJ_REVISION = $(addsuffix .o, $(REVISION_NAME)) ...@@ -79,15 +82,18 @@ OBJ_REVISION = $(addsuffix .o, $(REVISION_NAME))
OBJS_all = $(hal_OBJS) $(OBJ_REVISION) OBJS_all = $(hal_OBJS) $(OBJ_REVISION)
.PHONY: all kernel kernel_install kernel_check \ .PHONY: all kernel clean mrproper install uninstall tests examples \
clean mrproper install uninstall \ kernel_install kernel_uninstall kernel_check \
tests examples libclient libclient_install libclient_uninstall libclient_mrproper \
hal_install hal_uninstall hal_clean hal_mrproper \
tests tests_clean tests_mrproper \
examples_clean examples_mrproper
# Avoid deletion of intermediate files, such as objects # Avoid deletion of intermediate files, such as objects
.SECONDARY: $(OBJS_all) .SECONDARY: $(OBJS_all)
# Makefile rules # Makefile rules
all: kernel_check $(OUT) all: kernel $(OUT) libclient
# Output Rule # Output Rule
$(OUT): $$($$@_OBJS) $(REVISION_NAME).o $(OUT): $$($$@_OBJS) $(REVISION_NAME).o
...@@ -126,7 +132,7 @@ $(REVISION_NAME).o: $(REVISION_NAME).c ...@@ -126,7 +132,7 @@ $(REVISION_NAME).o: $(REVISION_NAME).c
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp @rm -f $*.d.tmp
kernel: kernel: kernel_check
$(MAKE) -C $(KERNEL_DIR) all $(MAKE) -C $(KERNEL_DIR) all
#Verify if the driver is in place #Verify if the driver is in place
...@@ -136,35 +142,67 @@ ifeq ($(wildcard $(DRIVER_OBJ)),) ...@@ -136,35 +142,67 @@ ifeq ($(wildcard $(DRIVER_OBJ)),)
@echo "Compilation will continue, but you must install"; @echo "Compilation will continue, but you must install";
@echo "and load the driver prior to initializing the software"; @echo "and load the driver prior to initializing the software";
@sleep 2; @sleep 2;
$(MAKE) -C $(KERNEL_DIR) all
endif endif
kernel_install: kernel_install:
$(MAKE) -C $(KERNEL_DIR) install $(MAKE) -C $(KERNEL_DIR) install
tests: kernel_uninstall:
$(MAKE) -C $@ all $(MAKE) -C $(KERNEL_DIR) uninstall
examples: kernel_clean:
$(MAKE) -C $@ all $(MAKE) -C $(KERNEL_DIR) clean
libclient:
$(MAKE) -C $(LIBCLIENT_DIR) all
libclient_install:
$(MAKE) -C $(LIBCLIENT_DIR) install
libclient_uninstall:
$(MAKE) -C $(LIBCLIENT_DIR) uninstall
#install: libclient_clean:
# @install -m 755 $(TARGET_SHARED_VER) $(INSTALL_DIR) $(MAKE) -C $(LIBCLIENT_DIR) clean
# $(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/$(lib) $(CMDSEP))
#
#uninstall:
# $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib).$(LIB_VER) $(CMDSEP))
# $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP))
clean: libclient_mrproper:
$(MAKE) -C $(LIBCLIENT_DIR) mrproper
hal_install:
$(foreach hal_bin,$(OUT),install -m 755 $(hal_bin) $(INSTALL_DIR)/bin $(CMDSEP))
hal_uninstall:
$(foreach hal_bin,$(OUT),rm -f $(INSTALL_DIR)/bin/$(hal_bin) $(CMDSEP))
hal_clean:
rm -f $(OBJS_all) $(OBJS_all:.o=.d) rm -f $(OBJS_all) $(OBJS_all:.o=.d)
$(MAKE) -C tests clean
$(MAKE) -C examples clean
$(MAKE) -C libclient clean
$(MAKE) -C $(KERNEL_DIR) clean
mrproper: clean hal_mrproper:
rm -f $(OUT) rm -f $(OUT)
tests:
$(MAKE) -C tests all
tests_clean:
$(MAKE) -C tests clean
tests_mrproper:
$(MAKE) -C tests mrproper $(MAKE) -C tests mrproper
examples:
$(MAKE) -C examples all
examples_clean:
$(MAKE) -C examples clean
examples_mrproper:
$(MAKE) -C examples mrproper $(MAKE) -C examples mrproper
$(MAKE) -C libclient mrproper
install: hal_install kernel_install libclient_install
uninstall: hal_uninstall kernel_uninstall libclient_uninstall
clean: hal_clean kernel_clean libclient_clean examples_clean tests_clean
mrproper: clean hal_mrproper libclient_mrproper examples_mrproper libclient_mrproper
...@@ -11,11 +11,14 @@ OBJCOPY = $(CROSS_COMPILE)objcopy ...@@ -11,11 +11,14 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size SIZE = $(CROSS_COMPILE)size
MAKE = make MAKE = make
INSTALL_DIR ?= /usr/local/lib INSTALL_DIR ?= /usr/local
export INSTALL_DIR export INSTALL_DIR
# Config variables suitable for creating shared libraries # Config variables suitable for creating shared libraries
LIB_VER = 1.0.0 LIB_VER_MAJOR = 1
LIB_VER_MINOR = 0
LIB_VER_REVISION = 0
LIB_VER = $(LIB_VER_MAJOR).$(LIB_VER_MINOR).$(LIB_VER_REVISION)
# General C flags # General C flags
CFLAGS = -std=gnu99 -O2 -fPIC CFLAGS = -std=gnu99 -O2 -fPIC
...@@ -53,8 +56,11 @@ OBJS_PLATFORM = ../hal/debug/debug_print.o ...@@ -53,8 +56,11 @@ OBJS_PLATFORM = ../hal/debug/debug_print.o
libbpmclient_OBJS_LIB = bpm_client.o bpm_client_err.o libbpmclient_OBJS_LIB = bpm_client.o bpm_client_err.o
# Include directories # Include directories
INCLUDE_DIRS = -I. -I../hal/include -I../hal/debug -I../hal/sm_io/modules/ \ INCLUDE_DIRS = -I. -I../hal/include -I../hal/debug \
-I../hal/sm_io/modules/fmc130m_4ch -I../hal/sm_io/modules/acq -I../hal/sm_io/modules/ \
-I../hal/sm_io/modules/fmc130m_4ch \
-I../hal/sm_io/modules/acq \
-I/usr/local/include
# Merge all flags. Optimize for size (-Os) # Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
...@@ -155,16 +161,18 @@ FORCE: ...@@ -155,16 +161,18 @@ FORCE:
# $(MAKE) -C $@ all # $(MAKE) -C $@ all
install: install:
$(foreach lib,$(TARGET_SHARED_VER),install -m 755 $(lib) $(INSTALL_DIR) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED_VER),install -m 755 $(lib) $(INSTALL_DIR)/lib $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/$(lib) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/lib/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_STATIC),install -m 755 $(lib) $(INSTALL_DIR) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/lib/$(lib).$(LIB_VER_MAJOR) $(CMDSEP))
$(foreach header,$($(LIBCLIENT)_HEADERS),install -m 755 $(header) $(INSTALL_DIR) $(CMDSEP)) $(foreach lib,$(TARGET_STATIC),install -m 755 $(lib) $(INSTALL_DIR)/lib $(CMDSEP))
$(foreach header,$($(LIBCLIENT)_HEADERS),install -m 755 $(header) $(INSTALL_DIR)/include $(CMDSEP))
uninstall: uninstall:
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib).$(LIB_VER) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib).$(LIB_VER) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_STATIC),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP)) $(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib).$(LIB_VER_MAJOR) $(CMDSEP))
$(foreach header,$(notdir $($(LIBCLIENT)_HEADERS)),rm -f $(INSTALL_DIR)/$(header) $(CMDSEP)) $(foreach lib,$(TARGET_STATIC),rm -f $(INSTALL_DIR)/lib/$(lib) $(CMDSEP))
$(foreach header,$(notdir $($(LIBCLIENT)_HEADERS)),rm -f $(INSTALL_DIR)/include/$(header) $(CMDSEP))
clean: clean:
rm -f $(OBJS_all) $(OBJS_all:.o=.d) $(REVISION_NAME).o rm -f $(OBJS_all) $(OBJS_all:.o=.d) $(REVISION_NAME).o
......
.PHONY: clean mrproper .PHONY: clean mrproper
clean: ; all:
mrproper: clean ; clean:
mrproper: clean
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment