Skip to content

Commit

Permalink
csal: demos: Update makefiles
Browse files Browse the repository at this point in the history
All makefiles updated to check .h dependencies.

Demos makefile updated to fix LPAE / VA64 issues.

Master makefile adds 'rebuild' target

Signed-off-by: Mike Leach <[email protected]>
  • Loading branch information
mikel-armbb committed Jan 24, 2017
1 parent c21d8fb commit 0c966ab
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
22 changes: 16 additions & 6 deletions build/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,19 @@ INCS= -I. \

# build rules for the .a lib
$(BUILD_DIR)/a/%.o: %.c
$(CC) $(CFLAGS) $(INCS) -c $< -o $@
$(CC) $(CFLAGS) $(INCS) -MMD -MP -c $< -o $@
A_OBJS=$(addprefix $(BUILD_DIR)/a/,$(CSSRC:%.c=%.o))
A_OBJS_UTIL=$(addprefix $(BUILD_DIR)/a/,$(CSUTILSRC:%.c=%.o))
A_DEPS=$(A_OBJS:.o=.d)
A_DEPS_UTIL=$(A_OBJS_UTIL:.o=.d)

# build rules for the .so lib
$(BUILD_DIR)/so/%.o: %.c
$(CC) $(CFLAGS) -fPIC $(INCS) -c $< -o $@
$(CC) $(CFLAGS) -fPIC $(INCS) -MMD -MP -c $< -o $@
SO_OBJS=$(addprefix $(BUILD_DIR)/so/,$(CSSRC:%.c=%.o))
SO_OBJS_UTIL=$(addprefix $(BUILD_DIR)/so/,$(CSUTILSRC:%.c=%.o))
SO_DEPS=$(SO_OBJS:.o=.d)
SO_DEPS_UTIL=$(SO_OBJS_UTIL:.o=.d)

# build both lib types
.PHONY: all
Expand Down Expand Up @@ -175,6 +179,12 @@ lib$(LIB_NAME).so: $(SO_OBJS)
lib$(LIB_NAME_UTIL).so: $(SO_OBJS_UTIL)
$(CC) -shared -o $(LIB_DIR)/lib$(LIB_NAME_UTIL).so $(SO_OBJS_UTIL)

# include generated dependency files
-include $(A_DEPS)
-include $(A_DEPS_UTIL)
-include $(SO_DEPS)
-include $(SO_DEPS_UTIL)


# clean all object files and libraries
.PHONY: clean
Expand All @@ -184,9 +194,9 @@ clean: clean_objs

.PHONY: clean_objs
clean_objs:
rm -fr $(A_OBJS)
rm -fr $(A_OBJS_UTIL)
rm -fr $(SO_OBJS)
rm -fr $(SO_OBJS_UTIL)
rm -fr $(A_OBJS) $(A_DEPS)
rm -fr $(A_OBJS_UTIL) $(A_DEPS_UTIL)
rm -fr $(SO_OBJS) $(SO_DEPS)
rm -fr $(SO_OBJS_UTIL) $(SO_DEPS_UTIL)


36 changes: 26 additions & 10 deletions demos/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,20 @@ else
CFLAGS+= -O2 -g
endif

# LPAE options
ifeq ($(LPAE),1)
# check if building on/for aarch64
ifeq ($(ARCH),arm64)
CFLAGS+= -DCS_VA64BIT
ifneq ($(NOLPAE),1)
CFLAGS+= -DLPAE
endif

# 64 bit VAs
ifeq ($(VA64),1)
CFLAGS+= -DCS_VA64BIT
else
# arm 32 - might want lpae
ifeq ($(LPAE),1)
CFLAGS+= -DLPAE
endif

endif

# set the include paths - for the CS Access library API
INCS= -I. \
Expand All @@ -73,7 +77,8 @@ INCS= -I. \

# build rules for the executables
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) $(CFLAGS_EX) $(INCS) -c $< -o $@
$(CC) $(CFLAGS) $(CFLAGS_EX) $(INCS) -c -MMD -MP $< -o $@


# library dependencies
LIB_NAME=csaccess
Expand Down Expand Up @@ -101,6 +106,7 @@ $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a:
CSLS_SRC=csls.c

CSLS_OBJS=$(addprefix $(BUILD_DIR)/,$(CSLS_SRC:%.c=%.o))
CSLS_DEPS=$(CSLS_OBJS:.o=.d)

csls: bin_dir $(CSLS_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(BIN_DIR)/makefile
$(CC) -o $(BIN_DIR)/$@ $(CSLS_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a
Expand All @@ -110,6 +116,7 @@ CSTD_SRC= tracedemo.c \
cs_demo_known_boards.c

CSTD_OBJS=$(addprefix $(BUILD_DIR)/,$(CSTD_SRC:%.c=%.o))
CSTD_DEPS=$(CSTD_OBJS:.o=.d)

tracedemo: bin_dir $(CSTD_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a $(BIN_DIR)/makefile
$(CC) -o $(BIN_DIR)/$@ $(CSTD_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a
Expand All @@ -119,6 +126,7 @@ CSTDCTI_SRC=tracedemo_cti_stop.c \
cs_demo_known_boards.c

CSTDCTI_OBJS=$(addprefix $(BUILD_DIR)/,$(CSTDCTI_SRC:%.c=%.o))
CSTDCTI_DEPS=$(CSTDCTI_OBJS:.o=.d)

trace_cti_stop: bin_dir $(CSTDCTI_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a $(BIN_DIR)/makefile
$(CC) -o $(BIN_DIR)/$@ $(CSTDCTI_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a
Expand All @@ -128,11 +136,19 @@ CSETM_SRC= cs_etm_config_demo.c \
cs_demo_known_boards.c

CSETM_OBJS=$(addprefix $(BUILD_DIR)/,$(CSETM_SRC:%.c=%.o))
CSETM_DEPS=$(CSETM_OBJS:.o=.d)


etmdemo: bin_dir $(CSETM_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a $(BIN_DIR)/makefile
$(CC) -o $(BIN_DIR)/$@ $(CSETM_OBJS) $(CS_LIB_DIR)/lib$(LIB_NAME).a $(CS_LIB_DIR)/lib$(LIB_NAME_UTIL).a


# include dependencies
-include $(CSLS_DEPS)
-include $(CSTD_DEPS)
-include $(CSTDCTI_DEPS)
-include $(CSETM_DEPS)

# copy the snapshot makefile
$(BIN_DIR)/makefile:
cp makefile.snapshot $(BIN_DIR)/makefile
Expand All @@ -148,8 +164,8 @@ clean: clean_objs

.PHONY: clean_objs
clean_objs:
rm -fr $(CSLS_OBJS)
rm -fr $(CSTD_OBJS)
rm -fr $(CSETM_OBJS)
rm -fr $(CSTDCTI_OBJS)
rm -fr $(CSLS_OBJS) $(CSLS_DEPS)
rm -fr $(CSTD_OBJS) $(CSTD_DEPS)
rm -fr $(CSETM_OBJS) $(CSTDCTI_DEPS)
rm -fr $(CSTDCTI_OBJS) $(CSETM_DEPS)

3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ experimental_clean:
python_clean:
cd ./python && make clean

#### rebuild
.PHONY: rebuild
rebuild: clean all

###### library maintenance operaions ##################################
# CS Lib API Documentation
Expand Down

0 comments on commit 0c966ab

Please sign in to comment.