GNU & BSD Makefile Directives & Conditions Compatibility


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting GNU & BSD Makefile Directives & Conditions Compatibility
# 1  
Old 10-17-2014
Question GNU & BSD Makefile Directives & Conditions Compatibility

Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong.

Secondly, I am not interested in dealing with autotools/autogen yet. I want to focus on learning about make/gmake.


I have seen this subject posted on the web, but have not found a solution for myself yet.

I want users to be able to compile from my Makefile on Linux, BSD, & Windows systems. The makefile tests if the target platform is Win32 using conditional directives. I much prefer BSD as the GNU syntax is confusing to me:
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
.if defined(WIN32) || defined(__WIN32__)
  EXESUFFIX=.exe
  ICON=myabcs.ico
.endif
...

However this is not compatible with GNU make:
Quote:
$ gmake
Makefile:20: *** missing separator. Stop.
For GNU make it needs to be something like this:
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
ifdef WIN32 # don't know how to use logical "or" (||) here
  EXESUFFIX=.exe
  ICON=myabcs.ico
endif
ifdef __WIN32__
  EXESUFFIX=.exe
  ICON=myabcs.ico
endif
...

or I think I can use something like this (though this example doesn't work as intented):
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
ifeq (,$(filter "",$(WIN32) $(__WIN32__)))
  EXESUFFIX=.exe
  ICON=myabcs.ico
endif
...

Neither of which are compatible with BSD make

My base question is how to make my Makefile both GNU & BSD compatible. Is it possible to do within a single file or do I need to separate them? Can I have a base makefile that imports another of either GNU or BSD standards? Or, do I just need to make 2 completely separate files?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash: How to use read with conditions & loops

Hello, Below I try to control that the input is good an IP : #!/bin/bash cp /home/scripts/choice_interfaces.txt /home/scripts/interfaces.txt chmod 644 /home/scripts/interfaces.txt echo -e "Please enter the network informations into the /etc/network/interfaces file, complete them below... (9 Replies)
Discussion started by: Arnaudh78
9 Replies

2. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

3. Shell Programming and Scripting

Compatibility issues between Sun solaries & AIX commands.

Hi, I am migrating few of the shell scripts from existing SUN Solaries to AIX. My script contains some command like 'dos2unix' and 'unix2dos' which are not compatible in AIX flavour. Please let me know if there is any such commands in AIX which can replace these commands. Thanks. (1 Reply)
Discussion started by: 46019
1 Replies

4. UNIX for Advanced & Expert Users

AND && in ifeq in makefile

Hi, Can anybody help mw how to use 2 conditinal directives in makefile (with AND=&&), so far none of my tries succedded. Getting this warning like below. I thought that C's && will work, but alas, played with (), spaces and etc.. and I have only GNU Make 3.80 ifeq ($(VAR1),15) &&... (4 Replies)
Discussion started by: trento17
4 Replies

5. Solaris

Compatibility between Unix & Windows

Pl. let me know whether Sun Solaris Server (Unix OS) is compatible with Windows Server or Vise Versa. Can i update the data first in Windows Server and then copied it to Sun Solaris Server or Vise Versa. (1 Reply)
Discussion started by: seemaitri
1 Replies

6. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

7. Shell Programming and Scripting

multiple conditions in if using && operator

VARIABLE="project" if && ] then echo "VARIABLE is not empty" fi this is not working what is wrong in the syntax?? (2 Replies)
Discussion started by: codeman007
2 Replies

8. Shell Programming and Scripting

if statement with two conditions -e, &&

Wow I'm so zoned out I don't even know if I posted this question up already (I couldn't find it in my book marks or in "yesterday's" post). My question is, I'm writing a korn script that does something like the following, but I don't yet completely understand the syntax. I need to check that... (16 Replies)
Discussion started by: yongho
16 Replies

9. UNIX for Dummies Questions & Answers

Linux & Unix Compatibility

I am looking for a dual XEON or any dual CPU motherboard that can support Linux and Solaris at the same time. Does anyone have any idea? I am now looking at the TYAN S2507T / TYAN S2505T / TYAN S2720, you guys have any clue?:confused: (6 Replies)
Discussion started by: doyho
6 Replies

10. UNIX for Dummies Questions & Answers

Unix & Processor compatibility

subject is self explanitory... can i install Unix on a system w/ and AMD processor (1 Reply)
Discussion started by: goliath3021
1 Replies
Login or Register to Ask a Question