github twitter email rss
Make Makefile CMake
0001 Jun 1
2 minutes read

Make

http://en.wikipedia.org/wiki/Make_(software)

Makefile examples

makefile

	all: build

	build:
		for f in *.applescript; do \
		    osacompile -o "$$(basename "$$f" .applescript).app" "$$f"; \
		done;

	install: build
		mkdir -p ~/Library/Scripts/Applications/Finder; cp -r *.app $$_;
all: build run

build:
    python3 setup.py py2app -A

run: build
    ./dist/installerx.app/Contents/MacOS/installerx

clean:
    rm -rf build dist
    CFLAGS ?= -g
 
    all: helloworld
 
    helloworld: helloworld.o
            # Commands start with TAB not spaces
            $(CC) $(LDFLAGS) -o $@ $^
 
    helloworld.o: helloworld.c
            $(CC) $(CFLAGS) -c -o $@ $<
 
    clean: FRC
            rm -f helloworld helloworld.o
 
    # This pseudo target causes all targets that depend on FRC
    # to be remade even in case a file with the name of the target exists.
    # This works with any make implementation under the assumption that
    # there is no file FRC in the current directory.
    FRC:
CC        = gcc -g
XFLAGS    = -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes \
            -DDEBUG -Wredundant-decls
#CC        = cc -g
#XFLAGS    =
UFLAGS    = # Always overrideable on the command line

DEPEND.mk  = sqlcmd-depend.mk
INSTALL.mk = sqlcmd-install.mk

ESQLC_VERSION = `esqlcver`
OFLAGS    = # -DDEBUG_MALLOC -g
OFLAGS    = -g -DDEBUG -O4
PFLAGS    = -DHAVE_CONFIG_H
OFILES.o  = # rfnmanip.o # malloc.o # strdup.o # memmove.o
VERSION   = -DESQLC_VERSION=${ESQLC_VERSION}
#INC1     = <defined in sqlcmd-depend.mk>
#INC2     = <defined in sqlcmd-depend.mk>
INC3      = /usr/gnu/include
INC4      = ${INFORMIXDIR}/incl/esql
INC5      = . #${INFORMIXDIR}/incl
INCDIRS   = -I${INC3} -I${INC1} -I${INC2} -I${INC4} -I${INC5}
LIBSQLCMD = libsqlcmd.a
STRIP     = #-s
LIBC      = #-lc_s
LIBMALLOC = #-lefence
LIBRDLN   = -lreadline
LIBCURSES = -lcurses
LIBPOSIX4 = -lposix4
LIBG      = #-lg
LIBDIR1   = ${HOME}/lib
LIBDIR2   = /usr/gnu/lib
LIBJL1    = ${LIBDIR1}/libjl.a
LIBJL2    = ${LIBDIR1}/libjlss-${ESQLC_VERSION}.a
LIBTOOLS  = ${LIBJL2} ${LIBJL1}
LDFLAGS   = ${LIBSQLCMD} ${LIBTOOLS} -L${LIBDIR2} ${LIBG} ${LIBMALLOC} \
            ${LIBPOSIX4} ${LIBC} ${STRIP}
CFLAGS    = ${VERSION} ${INCDIRS} ${OFLAGS} ${XFLAGS} ${PFLAGS} ${UFLAGS}

Automake

Cmake

cmake -G Xcode
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
add_executable(Tutorial tutorial.cxx)
cmake_minimum_required(VERSION 2.8)
project(test)
include(ExternalProject)
ExternalProject_Add(libantlr
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libantlr
    CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/libantlr/configure --prefix=<INSTALL_DIR>
    BUILD_COMMAND ${MAKE})
include(ExternalProject)
ExternalProject_Add(
  libantlr3c
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3/configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  BUILD_COMMAND make
  BUILD_IN_SOURCE 1
)
ExternalProject_Add(project_a
  URL ...project_a.tar.gz
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/project_a
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)

ExternalProject_Get_Property(project_a install_dir)
include_directories(${install_dir}/include)

add_dependencies(project_b_exe project_a)
target_link_libraries(project_b_exe ${install_dir}/lib/alib.lib)

Back to posts


comments powered by Disqus