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
# Select board in which we will work. Options are: ml605, afc
BOARD = ml605
INSTALL_DIR ?= /usr/lib
INSTALL_DIR ?= /usr/local
export INSTALL_DIR
# Kernel stuff (pcie driver and library) relative
......@@ -23,6 +23,9 @@ KERNEL_DIR = kernel
KERNEL_VER = $(shell uname -r)
DRIVER_OBJ = /lib/modules/$(KERNEL_VER)/extra/pciDriver.ko
# Client library
LIBCLIENT_DIR=libclient
# General C flags
CFLAGS = -std=gnu99 -O2 -DWR_SHIFT=2
......@@ -79,15 +82,18 @@ OBJ_REVISION = $(addsuffix .o, $(REVISION_NAME))
OBJS_all = $(hal_OBJS) $(OBJ_REVISION)
.PHONY: all kernel kernel_install kernel_check \
clean mrproper install uninstall \
tests examples
.PHONY: all kernel clean mrproper install uninstall tests examples \
kernel_install kernel_uninstall kernel_check \
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
.SECONDARY: $(OBJS_all)
# Makefile rules
all: kernel_check $(OUT)
all: kernel $(OUT) libclient
# Output Rule
$(OUT): $$($$@_OBJS) $(REVISION_NAME).o
......@@ -126,7 +132,7 @@ $(REVISION_NAME).o: $(REVISION_NAME).c
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
kernel:
kernel: kernel_check
$(MAKE) -C $(KERNEL_DIR) all
#Verify if the driver is in place
......@@ -136,35 +142,67 @@ ifeq ($(wildcard $(DRIVER_OBJ)),)
@echo "Compilation will continue, but you must install";
@echo "and load the driver prior to initializing the software";
@sleep 2;
$(MAKE) -C $(KERNEL_DIR) all
endif
kernel_install:
$(MAKE) -C $(KERNEL_DIR) install
tests:
$(MAKE) -C $@ all
kernel_uninstall:
$(MAKE) -C $(KERNEL_DIR) uninstall
examples:
$(MAKE) -C $@ all
kernel_clean:
$(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:
# @install -m 755 $(TARGET_SHARED_VER) $(INSTALL_DIR)
# $(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))
libclient_clean:
$(MAKE) -C $(LIBCLIENT_DIR) clean
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)
$(MAKE) -C tests clean
$(MAKE) -C examples clean
$(MAKE) -C libclient clean
$(MAKE) -C $(KERNEL_DIR) clean
mrproper: clean
hal_mrproper:
rm -f $(OUT)
tests:
$(MAKE) -C tests all
tests_clean:
$(MAKE) -C tests clean
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 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
SIZE = $(CROSS_COMPILE)size
MAKE = make
INSTALL_DIR ?= /usr/local/lib
INSTALL_DIR ?= /usr/local
export INSTALL_DIR
# 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
CFLAGS = -std=gnu99 -O2 -fPIC
......@@ -53,8 +56,11 @@ OBJS_PLATFORM = ../hal/debug/debug_print.o
libbpmclient_OBJS_LIB = bpm_client.o bpm_client_err.o
# Include directories
INCLUDE_DIRS = -I. -I../hal/include -I../hal/debug -I../hal/sm_io/modules/ \
-I../hal/sm_io/modules/fmc130m_4ch -I../hal/sm_io/modules/acq
INCLUDE_DIRS = -I. -I../hal/include -I../hal/debug \
-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)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
......@@ -155,16 +161,18 @@ FORCE:
# $(MAKE) -C $@ all
install:
$(foreach lib,$(TARGET_SHARED_VER),install -m 755 $(lib) $(INSTALL_DIR) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_STATIC),install -m 755 $(lib) $(INSTALL_DIR) $(CMDSEP))
$(foreach header,$($(LIBCLIENT)_HEADERS),install -m 755 $(header) $(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/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),ln -sf $(lib).$(LIB_VER) $(INSTALL_DIR)/lib/$(lib).$(LIB_VER_MAJOR) $(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:
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib).$(LIB_VER) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_STATIC),rm -f $(INSTALL_DIR)/$(lib) $(CMDSEP))
$(foreach header,$(notdir $($(LIBCLIENT)_HEADERS)),rm -f $(INSTALL_DIR)/$(header) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib).$(LIB_VER) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib) $(CMDSEP))
$(foreach lib,$(TARGET_SHARED),rm -f $(INSTALL_DIR)/lib/$(lib).$(LIB_VER_MAJOR) $(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:
rm -f $(OBJS_all) $(OBJS_all:.o=.d) $(REVISION_NAME).o
......
.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