Linux/make/Examples

From Omnia
< Linux‎ | make
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Linux PKI Makefile

See Linux/make/Linux PKI Makefile

Makefile Tutorial by Example Advanced Makefile

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp hello.cpp factorial.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(SOURCES) $(EXECUTABLE)
	
$(EXECUTABLE): $(OBJECTS) 
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@

Source: http://mrbook.org/tutorials/make/

Hitachi Five FC HBA Kernel Module

#
# Makefile
#
# Copyright (C) 2007, Hitachi, Ltd.
# Author(s): Yoshihiro Toyohara <yoshihiro.toyohara.qs@hitachi.com>
#
# $Id: Makefile,v 1.20.2.1.2.1.2.4 2008/09/19 07:37:47 eteshima Exp $
#

HOSTTYPE := $(shell uname -m)
OSVER := $(shell uname -r)

EXTRA_CFLAGS := -D_LINUX_COM -D__LINUX -DHFC_ENHANCED -DHFC_NON_HOTPLUG

HOSTTYPE := $(shell uname -m)
ifeq ($(HOSTTYPE),ia64)
	EXTRA_CFLAGS += -DHFC_IA64_AS4
endif
ifeq ($(HOSTTYPE),i686)
	EXTRA_CFLAGS += -DHFC_IA32_AS4
endif
ifeq ($(HOSTTYPE),x86_64)
	EXTRA_CFLAGS += -DHFC_X8664_AS4
endif

MODS = hraslog_link.ko hfcldd_conf.ko hfcldd.ko
OBJS = hraslog_link.o hfcldd_conf.o hfcldd.o
TARGET = $(MODS)

.PHONY: allup

all : hraslog_linkup hfcldd_confup hfclddup moveup

allup : hraslog_linkup hfcldd_confup hfclddup moveup

hraslog_linkup : hraslog_link.c
	make -C /lib/modules/$(OSVER)/build M=`pwd` V=1 modules  >> result.log  2>> result.log

hfcldd_confup : hfcldd_conf.c
	make -C /lib/modules/$(OSVER)/build M=`pwd` V=1 modules  >> result.log  2>> result.log

hfclddup : hfcl_conf.c hfcl_detect.c hfcl_handler.c hfcl_diag.c hfcl_strategy.c hfcl_timer_recovery.c \
	hfcl_top.c hfcl_ioctl.c hfcl_version.c hfcl_mlpf.c
	make -C /lib/modules/$(OSVER)/build M=`pwd` V=1 modules  >> result.log  2>> result.log

moveup :
	mkdir -p    $(OSVER)
	mv ./*.o    $(OSVER)/
	mv ./*.ko   $(OSVER)/
	mv ./.*.cmd $(OSVER)/
	mv ./*.log  $(OSVER)/


clean :
#	make -C /lib/modules/$(OSVER)/build M=`pwd` V=1 clean
	rm -rf $(OSVER)

obj-m:= $(OBJS)

hfcldd-objs := hfcl_conf.o hfcl_detect.o hfcl_handler.o hfcl_diag.o hfcl_strategy.o hfcl_timer_recovery.o \
hfcl_top.o hfcl_ioctl.o hfcl_version.o hfcl_mlpf.o

clean-files := *.o *.ko *.mod.[co]