Skip to content

Commit

Permalink
makefile update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Dec 13, 2011
1 parent 45edbf2 commit a92915a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 55 deletions.
43 changes: 21 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define make-lib
$(RANLIB) $(DLIB_PATH)$(PATH_SEP)$@
endef

############# BUILD #############
############# BUILD #############
all: static-lib header doc pkgfile
@echo ------------------ Building $^ done

Expand Down Expand Up @@ -82,53 +82,53 @@ $(SONAME): $(PICOBJECTS)

# create object files
$(BUILD_PATH)$(PATH_SEP)%.o : %.d
$(DC) $(DFLAGS) $(DFLAGS_LINK) $(DFLAGS_IMPORT) -c $< $(OUTPUT)$@
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $< $(OUTPUT)$@

# create shared object files
$(BUILD_PATH)$(PATH_SEP)%.pic.o : %.d
$(DC) $(DFLAGS) $(DFLAGS_LINK) $(FPIC) $(DFLAGS_IMPORT) -c $< $(OUTPUT)$@
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(FPIC) $(DCFLAGS_IMPORT) -c $< $(OUTPUT)$@

# Generate Header files
$(IMPORT_PATH)$(PATH_SEP)%.di : %.d
$(DC) $(DFLAGS) $(DFLAGS_LINK) $(DFLAGS_IMPORT) -c $(NO_OBJ) $< $(HF)$@
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $< $(HF)$@

# Generate Documentation
$(DOC_PATH)$(PATH_SEP)%.html : %.d
$(DC) $(DFLAGS) $(DFLAGS_LINK) $(DFLAGS_IMPORT) -c $(NO_OBJ) $< $(DF)$@
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $< $(DF)$@

# Generate ddoc Documentation
$(DDOC_PATH)$(PATH_SEP)%.html : %.d
$(DC) $(DFLAGS) $(DFLAGS_LINK) $(DFLAGS_IMPORT) -c $(NO_OBJ) $(DDOC_FLAGS) $< $(DF)$@
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $(DDOC_FLAGS) $< $(DF)$@

############# CLEAN #############
############# CLEAN #############
clean: clean-objects clean-static-lib clean-doc clean-header clean-pkgfile
@echo ------------------ Cleaning $^ done

clean-objects:
$(RM) $(OBJECTS)
@echo ------------------ Cleaning objects done

clean-shared-objects:
$(RM) $(PICOBJECTS)
@echo ------------------ Cleaning shared-object done

clean-static-lib:
$(RM) $(SONAME)
@echo ------------------ Cleaning static-lib done

clean-shared-lib:
$(RM) $(LIBNAME)
@echo ------------------ Cleaning shared-lib done

clean-header:
$(RM) $(HEADERS)
@echo ------------------ Cleaning header done

clean-doc:
$(RM) $(DOCUMENTATIONS)
$(RM) $(DOC_PATH)
@echo ------------------ Cleaning doc done

clean-ddoc:
$(RM) $(DDOC_PATH)$(PATH_SEP)index.html
$(RM) $(DDOC_PATH)
Expand All @@ -141,9 +141,9 @@ clean-geany-tag:
clean-pkgfile:
$(RM) $(PKG_CONFIG_FILE)
@echo ------------------ Cleaning pkgfile done

############# INSTALL #############

install: install-static-lib install-doc install-header install-pkgfile
@echo ------------------ Installing $^ done

Expand All @@ -156,21 +156,20 @@ install-shared-lib:
$(MKDIR) $(LIB_DIR)
$(CP) $(DLIB_PATH)$(PATH_SEP)$(SONAME) $(LIB_DIR)
@echo ------------------ Installing shared-lib done

install-header:
$(MKDIR) $(INCLUDE_DIR)
$(CP) $(IMPORT_PATH) $(INCLUDE_DIR)
$(CP) $(IMPORT_PATH)$(PATH_SEP)* $(INCLUDE_DIR)
@echo ------------------ Installing header done

install-doc:
$(MKDIR) $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)normal_doc$(PATH_SEP)
$(CP) $(DOC_PATH)$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)* $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)normal_doc$(PATH_SEP)
$(CP) $(DOC_PATH)$(PATH_SEP)* $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)normal_doc$(PATH_SEP)
@echo ------------------ Installing doc done

install-ddoc:
$(MKDIR) $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
$(CP) $(DDOC_PATH)$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)* $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
$(CP) $(DDOC_PATH)$(PATH_SEP)index.html $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
$(CP) $(DDOC_PATH)$(PATH_SEP)* $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
@echo ------------------ Installing ddoc done

install-geany-tag:
Expand All @@ -181,4 +180,4 @@ install-geany-tag:
install-pkgfile:
$(MKDIR) $(PKGCONFIG_DIR)
$(CP) $(PKG_CONFIG_FILE) $(PKGCONFIG_DIR)
@echo ------------------ Installing pkgfile done
@echo ------------------ Installing pkgfile done
66 changes: 33 additions & 33 deletions command.make
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ else
message = @(echo \033[31m $1 \033[0;0m1)
endif
endif

# Define command for copy, remove and create file/dir
ifeq ($(OS),"Windows")
RM = del /Q
Expand All @@ -45,7 +45,7 @@ else ifeq ($(OS),"Darwin")
MKDIR = mkdir -p
MV = mv
endif

# If compiler is not define try to find it
ifndef DC
ifneq ($(strip $(shell which dmd 2>/dev/null)),)
Expand All @@ -58,26 +58,26 @@ ifndef DC
DC=gdc
endif
endif

# Define flag for gdc other
ifeq ($(DC),gdc)
DFLAGS = -O2 -fdeprecated
LINKERFLAG= -Xlinker
DCFLAGS = -O2 -fdeprecated
LINKERFLAG= -Xlinker
OUTPUT = -o
HF = -fintfc-file=
DF = -fdoc-file=
NO_OBJ = -fsyntax-only
DDOC_MACRO= -fdoc-inc=
else
DFLAGS = -O -d
DCFLAGS = -O -d
LINKERFLAG= -L
OUTPUT = -of
HF = -Hf
DF = -Df
NO_OBJ = -o-
DDOC_MACRO=
endif

#define a suufix lib who inform is build with which compiler
ifeq ($(DC),gdc)
COMPILER=gdc
Expand All @@ -94,19 +94,19 @@ else ifeq ($(DC),dmd)
else ifeq ($(DC),dmd2)
COMPILER=dmd
endif

# Define relocation model for ldc or other
ifneq (,$(findstring ldc,$(DC)))
FPIC = -relocation-model=pic
else
FPIC = -fPIC
endif

# Add -ldl flag for linux
ifeq ($(OS),"Linux")
LDFLAGS += $(LINKERFLAG)-ldl
LDCFLAGS += $(LINKERFLAG)-ldl
endif

# If model are not gieven take the same as current system
ARCH = $(shell arch || uname -m)
ifndef MODEL
Expand All @@ -116,18 +116,18 @@ ifndef MODEL
MODEL = 32
endif
endif

ifeq ($(MODEL), 64)
DFLAGS += -m64
LDFLAGS += -m64
DCFLAGS += -m64
LDCFLAGS += -m64
else
DFLAGS += -m32
LDFLAGS += -m32
DCFLAGS += -m32
LDCFLAGS += -m32
endif

# Define var PREFIX, BIN_DIR, LIB_DIR, INCLUDE_DIR, DATA_DIR
ifndef PREFIX
ifeq ($(OS),"Windows")
ifeq ($(OS),"Windows")
PREFIX = $(PROGRAMFILES)
else ifeq ($(OS), "Linux")
PREFIX = /usr/local
Expand All @@ -137,7 +137,7 @@ ifndef PREFIX
endif

ifndef BIN_DIR
ifeq ($(OS), "Windows")
ifeq ($(OS), "Windows")
BIN_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\bin
else ifeq ($(OS), "Linux")
BIN_DIR = $(PREFIX)/bin
Expand All @@ -146,7 +146,7 @@ ifndef BIN_DIR
endif
endif
ifndef LIB_DIR
ifeq ($(OS), "Windows")
ifeq ($(OS), "Windows")
LIB_DIR = $(PREFIX)\$(PROJECT_NAME)\lib
else ifeq ($(OS), "Linux")
LIB_DIR = $(PREFIX)/lib
Expand All @@ -156,7 +156,7 @@ ifndef LIB_DIR
endif

ifndef INCLUDE_DIR
ifeq ($(OS), "Windows")
ifeq ($(OS), "Windows")
INCLUDE_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\import
else ifeq ($(OS), "Linux")
INCLUDE_DIR = $(PREFIX)/include/d/$(PROJECT_NAME)
Expand All @@ -166,7 +166,7 @@ ifndef INCLUDE_DIR
endif

ifndef DATA_DIR
ifeq ($(OS), "Windows")
ifeq ($(OS), "Windows")
DATA_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\data
else ifeq ($(OS), "Linux")
DATA_DIR = $(PREFIX)/share
Expand All @@ -176,28 +176,28 @@ ifndef DATA_DIR
endif

ifndef PKGCONFIG_DIR
ifeq ($(OS), "Windows")
ifeq ($(OS), "Windows")
PKGCONFIG_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\data
else ifeq ($(OS), "Linux")
PKGCONFIG_DIR = $(DATA_DIR)/pkgconfig
else ifeq ($(OS), "Darwin")
PKGCONFIG_DIR = $(DATA_DIR)/pkgconfig
endif
endif

ifndef CC
CC = gcc
endif

DLIB_PATH = ./lib
IMPORT_PATH = ./import
DOC_PATH = ./doc
DDOC_PATH = ./ddoc
BUILD_PATH = ./build
DFLAGS_IMPORT =
DFLAGS_LINK = $(LDFLAGS)

DCFLAGS_IMPORT = -I"gl3n/"
DCFLAGS_LINK = $(LDCFLAGS)

LIBNAME = lib$(PROJECT_NAME)-$(COMPILER)$(STATIC_LIB_EXT)
SONAME = lib$(PROJECT_NAME)-$(COMPILER)$(DYNAMIC_LIB_EXT)

Expand All @@ -219,9 +219,9 @@ export CP
export DATA_DIR
export DC
export DF
export DFLAGS
export DFLAGS_IMPORT
export DFLAGS_LINK
export DCFLAGS
export DCFLAGS_IMPORT
export DCFLAGS_LINK
export DLIB_PATH
export DOC_PATH
export DDOC_PATH
Expand All @@ -230,7 +230,7 @@ export FixPath
export HF
export INCLUDE_DIR
export IMPORT_PATH
export LDFLAGS
export LDCFLAGS
export FPIC
export LIBNAME
export LIB_DIR
Expand Down

0 comments on commit a92915a

Please sign in to comment.