Changeset 6d5c7cc in freewrt for Makefile


Ignore:
Timestamp:
Jun 11, 2006, 5:28:26 PM (20 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
aaafd63
Parents:
4a83e29
Message:

Initial cut at supporting FreeWRT builds under other operating
systems (MirOS BSD, OpenBSD, probably the other BSDs as well;
Mac OSX and Cygwin to come)

The basic idea is:

  • the old GNU make "Makefile" is renamed to "build.mk"
  • a wrapper Makefile which uses neither GNU nor BSD make features calls GNU make with -f build.mk
  • the wrapper Makefile also checks for prerequisite tools (as of now: existence of gmake and md5sum) and their versions (not yet, but that's why it's being used on GNU/Linux as well)
  • scripts/md5sum.bsd uses BSD cksum(1) to generate GNU md5sum compatible output (only when the arguments are files; no options are supported)
  • GNU make is symlinked into ./lbin/; md5sum.bsd is copied there if needed; ./lbin/ is prepended to $PATH for gmake -f build.mk invocations
  • make distclean removes prerequisites (and lbin)

git-svn-id: svn://www.freewrt.org/trunk/freewrt@41 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r4a83e29 r6d5c7cc  
    1 # Makefile for FreeWRT development environment
     1# $FreeWRT: src/share/misc/licence.template,v 1.7 2006/04/09 22:08:49 tg Rel $ */
     2#-
     3# Copyright (c) 2006
     4#       Thorsten Glaser <tg@mirbsd.de>
    25#
    3 # Copyright (C) 2005 by Felix Fietkau <openwrt@nbd.name>
    4 # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
     6# Licensee is hereby permitted to deal in this work without restric-
     7# tion, including unlimited rights to use, publicly perform, modify,
     8# merge, distribute, sell, give away or sublicence, provided all co-
     9# pyright notices above, these terms and the disclaimer are retained
     10# in all redistributions or reproduced in accompanying documentation
     11# or other materials provided with binary redistributions.
    512#
    6 # This program is free software; you can redistribute it and/or modify
    7 # it under the terms of the GNU General Public License as published by
    8 # the Free Software Foundation; either version 2 of the License, or
    9 # (at your option) any later version.
     13# All advertising materials mentioning features or use of this soft-
     14# ware must display the following acknowledgement:
     15#       This product includes material provided by Thorsten Glaser.
     16# This acknowledgement does not need to be reprinted if this work is
     17# linked into a bigger work whose licence does not allow such clause
     18# and the author of this work is given due credit in the bigger work
     19# or its documentation. Specifically, re-using this code in any work
     20# covered by the GNU General Public License version 1 or Library Ge-
     21# neral Public License (any version) is permitted.
    1022#
    11 # This program is distributed in the hope that it will be useful,
    12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    14 # General Public License for more details.
    15 #
    16 # You should have received a copy of the GNU General Public License
    17 # along with this program; if not, write to the Free Software
    18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    19 #
     23# Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind,
     24# express, or implied, to the maximum extent permitted by applicable
     25# law, without malicious intent or gross negligence; in no event may
     26# licensor, an author or contributor be held liable for any indirect
     27# or other damage, or direct damage except proven a consequence of a
     28# direct error of said person and intended use of this work, loss or
     29# other issues arising in any way out of its use, even if advised of
     30# the possibility of such damage or existence of a nontrivial bug.
    2031
    21 #--------------------------------------------------------------
    22 # Just run 'make menuconfig', configure stuff, then run 'make'.
    23 # You shouldn't need to mess with anything beyond this point...
    24 #--------------------------------------------------------------
    25 TOPDIR=${shell pwd}
    26 export TOPDIR
     32GMAKE?=         $(PWD)/lbin/gmake
     33GMAKE_INV=      PATH=$(PWD)/lbin:$(PATH) ${GMAKE} -f $(PWD)/build.mk ${VARS_TO_PASS}
    2734
    28 ifneq ($(DEVELOPER),)
    29 CONFIG_CONFIG_IN = Config.in.devel
    30 else
    31 CONFIG_CONFIG_IN = Config.in
    32 endif
    33 CONFIG = package/config
     35VARS_TO_PASS=   HOSTCC='${CC}' MAKE='${GMAKE}'
    3436
    35 noconfig_targets := menuconfig config oldconfig randconfig \
    36         allyesconfig allnoconfig tags
     37all: prereq
     38        ${GMAKE_INV} all
    3739
    38 # Pull in the user's configuration file
    39 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
    40 -include $(TOPDIR)/.config
    41 endif
     40clean: prereq
     41        ${GMAKE_INV} clean
    4242
    43 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
    44 include $(TOPDIR)/rules.mk
     43config: prereq
     44        ${GMAKE_INV} config
    4545
    46 all: world
     46dirclean: prereq
     47        ${GMAKE_INV} dirclean
    4748
    48 .NOTPARALLEL:
    49 .PHONY: all world clean dirclean distclean image_clean target_clean source configtest
     49distclean: prereq
     50        ${GMAKE_INV} distclean
     51        -rm -rf lbin
     52        -rm -f prereq
    5053
    51 #############################################################
    52 #
    53 # You should probably leave this stuff alone unless you know
    54 # what you are doing.
    55 #
    56 #############################################################
     54image_clean: prereq
     55        ${GMAKE_INV} image_clean
    5756
    58 # In this section, we need .config
    59 include .config.cmd
     57menuconfig: prereq
     58        ${GMAKE_INV} menuconfig
    6059
    61 world: $(DL_DIR) $(BUILD_DIR) configtest
    62         $(MAKE) toolchain/install target/compile package/compile root_clean package/install target/install package_index
    63         @$(TRACE) Build complete.
     60oldconfig: prereq
     61        ${GMAKE_INV} oldconfig
    6462
    65 configtest:
    66         -cp .config .config.test
    67         -scripts/configtest.pl
     63package_index: prereq
     64        ${GMAKE_INV} package_index
    6865
    69 package_index:
    70         (cd $(PACKAGE_DIR); $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages)
     66source: prereq
     67        ${GMAKE_INV} source
    7168
    72 $(DL_DIR):
    73         @mkdir -p $(DL_DIR)
     69target_clean: prereq
     70        ${GMAKE_INV} target_clean
    7471
    75 $(BUILD_DIR):
    76         @mkdir -p $(BUILD_DIR)
     72world: prereq
     73        ${GMAKE_INV} world
    7774
    78 source: toolchain/source package/source target/source
    79 
    80 package/%:
    81         @$(TRACE) $@
    82         $(MAKE) -C package $(patsubst package/%,%,$@)
    83 
    84 target/%:
    85         @$(TRACE) $@
    86         $(MAKE) -C target $(patsubst target/%,%,$@)
    87 
    88 toolchain/%:
    89         @$(TRACE) $@
    90         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
    91 
    92 #############################################################
    93 #
    94 # Cleanup and misc junk
    95 #
    96 #############################################################
    97 root_clean:
    98         @$(TRACE) root_clean
    99         rm -rf $(BUILD_DIR)/linux-*/root $(BUILD_DIR)/root
    100 
    101 target_clean: root_clean
    102         rm -f $(STAMP_DIR)/.*-compile
    103         rm -f $(STAMP_DIR)/.*-install
    104         rm -rf $(BIN_DIR)
    105 
    106 clean: dirclean
    107 
    108 dirclean:
    109         @$(TRACE) dirclean
    110         @$(MAKE) -C $(CONFIG) clean
    111         rm -rf $(BUILD_DIR) $(BIN_DIR)
    112 
    113 distclean: dirclean
    114         rm -rf $(STAMP_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
    115         rm -f .config* .tmpconfig.h
    116 
    117 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
    118 
    119 all: menuconfig
    120 
    121 # configuration
    122 # ---------------------------------------------------------------------------
    123 
    124 $(CONFIG)/conf:
    125         $(MAKE) -C $(CONFIG) conf
    126 $(CONFIG)/mconf:
    127         $(MAKE) -C $(CONFIG)
    128 
    129 menuconfig: $(CONFIG)/mconf
    130         -touch .config
    131         -cp .config .config.test
    132         @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
    133         -./scripts/configtest.pl
    134 
    135 config: $(CONFIG)/conf
    136         -touch .config
    137         -cp .config .config.test
    138         @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
    139         -./scripts/configtest.pl
    140 
    141 oldconfig: $(CONFIG)/conf
    142         -touch .config
    143         -cp .config .config.test
    144         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
    145         -./scripts/configtest.pl
    146 
    147 randconfig: $(CONFIG)/conf
    148         -touch .config
    149         -cp .config .config.test
    150         @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
    151         -./scripts/configtest.pl
    152 
    153 allyesconfig: $(CONFIG)/conf
    154         -touch .config
    155         -cp .config .config.test
    156         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
    157         -./scripts/configtest.pl
    158 
    159 allnoconfig: $(CONFIG)/conf
    160         -touch .config
    161         -cp .config .config.test
    162         @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
    163         -./scripts/configtest.pl
    164 
    165 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
     75prereq:
     76        -rm -rf prereq lbin
     77        mkdir lbin
     78        if which gmake >/dev/null 2>&1; then \
     79                ln -s $$(which gmake) lbin/gmake; \
     80        else \
     81                ln -s $$(which make) lbin/gmake; \
     82        fi
     83        if ! which md5sum >/dev/null 2>&1; then \
     84                cp scripts/md5sum.bsd lbin/md5sum; \
     85                chmod 555 lbin/md5sum; \
     86        fi
     87        touch $@
Note: See TracChangeset for help on using the changeset viewer.