Skip to content

Commit

Permalink
Makefile: prettify and allow easier cross-compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
  • Loading branch information
ezequielgarcia committed Jul 27, 2013
1 parent 3e3594a commit 49fe202
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
9 changes: 0 additions & 9 deletions config

This file was deleted.

50 changes: 32 additions & 18 deletions makefile
@@ -1,44 +1,58 @@

##############################################################################
## YOU SHOULD NOT EDIT THIS FILE, USE config INSTEAD
##

include config

DFB_INC_DIR = $(shell pkg-config --variable=includedir directfb)/directfb/
ifneq ("$(origin V)", "command line")
Q = @
endif

LUA = lua
CC = $(HOST_DIR)$(TARGET_NAME)gcc
AR = $(HOST_DIR)$(TARGET_NAME)ar
LD = $(CC)
RM = rm
STRIP = strip
ECHO = @echo
PKG_CONFIG = $(HOST_DIR)pkg-config

DFB_INC_DIR = $(shell $(PKG_CONFIG) --variable=includedir directfb)/directfb/
DFB_HEADER = $(DFB_INC_DIR)directfb_keyboard.h $(DFB_INC_DIR)directfb.h

CFLAGS = -Wall -fPIC $(shell pkg-config --cflags directfb $(LUA))
LDFLAGS = -shared $(shell pkg-config --libs directfb $(LUA))
INSTALL_DIR = $(shell pkg-config --variable INSTALL_CMOD $(LUA))
CFLAGS = -Wall -fPIC $(shell $(PKG_CONFIG) --cflags directfb $(LUA))
LDFLAGS = -shared $(shell $(PKG_CONFIG) --libs directfb $(LUA))
INSTALL_DIR = $(shell $(PKG_CONFIG) --variable INSTALL_CMOD $(LUA))

COMPAT_DIR := compat/
SRC_DIR := src/
SRC := $(wildcard $(SRC_DIR)*.c $(COMPAT_DIR)*.c)
OBJ = $(SRC:.c=.o)

OUTPUT=directfb.so

$(OUTPUT): $(SRC)
$(CC) $(CFLAGS) $(SRC) $(LDFLAGS) -o $@
$(OUTPUT): $(OBJ)
$(Q)$(ECHO) " LD "$@;
$(Q)$(LD) $^ $(LDFLAGS) -o $@

.c.o:
$(Q)$(ECHO) " CC "$@;
$(Q)$(CC) $(CFLAGS) -c $< -o $@

.gen.stamp: gendfb-lua.pl dir
cat $(DFB_HEADER) | ./gendfb-lua.pl || exit 1
touch .gen.stamp
$(Q)$(ECHO) "Generating from $(DFB_HEADER)"
$(Q)cat $(DFB_HEADER) | ./gendfb-lua.pl || exit 1
$(Q)touch .gen.stamp

tags: $(SRC_DIR)* $(DFB_HEADER)
ctags $(SRC_DIR)* $(DFB_HEADER)
$(Q)ctags $(SRC_DIR)* $(DFB_HEADER)

.PHONY: install
install: $(OUTPUT)
cp $(OUTPUT) $(INSTALL_DIR)
$(Q)cp $(OUTPUT) $(INSTALL_DIR)

.PHONY: clean
clean:
rm -f *.so $(SRC_DIR)* .gen.stamp
$(Q)rm -f *.so $(SRC_DIR)* .gen.stamp

.PHONY: gen
gen: .gen.stamp

.PHONY: dir
dir:
mkdir -p src
$(Q)mkdir -p src

0 comments on commit 49fe202

Please sign in to comment.