From nobody Wed Feb 07 19:36:33 2024 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TVVkG5294z59x5t for ; Wed, 7 Feb 2024 19:37:10 +0000 (UTC) (envelope-from m.e.sanliturk@gmail.com) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TVVkG2bhZz3wjf; Wed, 7 Feb 2024 19:37:10 +0000 (UTC) (envelope-from m.e.sanliturk@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6e112a5d30cso398195a34.2; Wed, 07 Feb 2024 11:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707334629; x=1707939429; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gTBJFl/toEp4GKUEh0bgDRzS6gCpSS0IA5779McxFCs=; b=ZJ5FSCgPTjI29kjGAHx8QONusk/mFBzEo9Sy4+Q3zvuTVgt6cWuTP1WVFplRyKTube B/wLmHIE/CC5HLTFUFbmNUWsOTtV30vRGMQSXa+8aXcxbtDpXjb1WircjBAa+KMgsFV6 9GX1+PMEXM7hKFx1En98k7emIzR1ikxzbg7U7vjafPBLs0doE4BGhPziqPtaolWw6DbD Pz7A18sRDBcf/UjM16eDu1mISxx73eKj2KH4Dv51U530ByeuAxNFeghDAp8lHdhSn02p dbK4fOj6yYFkNcHiRf88VlAXpVO97cVj/Qc4eOnODTbouExjWb15na+c/v1YBsUeb/xt tkog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707334629; x=1707939429; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gTBJFl/toEp4GKUEh0bgDRzS6gCpSS0IA5779McxFCs=; b=RDIUdngumJBqXbOjdxmdXZzF7+03rAaKz3U/Qc0+7CPsBlOukRC2p08rRVbSOCBvmb BkLbI9Qjmj0wX/tRGib1bp6O0K/x6tCsTcYX37oueuRd290gYhqOI/mWXRC9uXucJYeh YngHFOxQEPm5rhzsbLJRKYKfwuX3C6jEm/Hf6SYIxD2My6OAQOC1wkEz9tmCbFGRuYQD EuInC9iy2qYlLeKdruGj4Ld6tzC/PBBupNW+jMKYrgiGaQsiqRIwTZ7ta0loeqZBWxj/ csaKrzh4RMpagsZsEyNjzcrQHYpAmqoQn3x7lUokpywAJANiwdMeNkO/oc1ITL7kTmdR WM1A== X-Forwarded-Encrypted: i=1; AJvYcCXlifiAeTHLaMMuAKjEc8Sa9k7lA6Gi2D4XDYM8UFtG2ORj0ulc/m2cXR/WDSf4mXHlJaNvf/G0yOn9JzInO0OccyP22+bVMwtdFhMBbA== X-Gm-Message-State: AOJu0Ywen+G4X408KB5EqBYSghuAmGRhXLslZHZWVmhxDvseySFFVumj k2p8dgMJ7FhnbLBCvom40VrVq6YRa8WEiGk2r2EgiYj77sEbgWjyd23mho1J54xQMlwZcgYAprO gbLQBhoSM+JAB3/CmUzB5DR6WNdIIMghU X-Google-Smtp-Source: AGHT+IEFSMa03eRc10XgD9rpwQRkjsopiCkDAy9n1DALqDsg3JHofy/0ynUU0QV+yc9wKWcHi5IqgNgys+wZz/QIOsY= X-Received: by 2002:a9d:7a43:0:b0:6e2:b6f8:a6b3 with SMTP id z3-20020a9d7a43000000b006e2b6f8a6b3mr3669406otm.36.1707334629115; Wed, 07 Feb 2024 11:37:09 -0800 (PST) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 References: <8_kmThiamXBYyS8xs6DcL-Sdkr244nfiKNXas7jkXifkzGss3sleWGJN6n4BV7jof6jpKK9vHnYVpKImQHAbGuGlJindprbvtRFh04q_PI4=@proton.me> In-Reply-To: <8_kmThiamXBYyS8xs6DcL-Sdkr244nfiKNXas7jkXifkzGss3sleWGJN6n4BV7jof6jpKK9vHnYVpKImQHAbGuGlJindprbvtRFh04q_PI4=@proton.me> From: Mehmet Erol Sanliturk Date: Wed, 7 Feb 2024 22:36:33 +0300 Message-ID: Subject: Re: Need help with a makefile [RESOLVED] To: Jonathan Adams Cc: "Greg 'groggy' Lehey" , freebsd-questions@freebsd.org Content-Type: multipart/alternative; boundary="00000000000014cdd60610cfd285" X-Rspamd-Queue-Id: 4TVVkG2bhZz3wjf X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --00000000000014cdd60610cfd285 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 7, 2024 at 10:10=E2=80=AFPM Jonathan Adams wrote: > On Tuesday, February 6th, 2024 at 10:38 PM, Greg 'groggy' Lehey < > grog@freebsd.org> wrote: > > > However, I've put this through gmake, and it complains: > > > > $ gmake > > Makefile:7: extraneous text after 'ifeq' directive > > Hi Greg, et al., > The above error was do to the line continuation backslashes. Installed > gmake, took out the backslashes and, presto, it "just works". On FBSD, th= at > is. > In my little project, I was using getpass(), but have changed to > readpassphrase(). Great, but on Linux that's in /usr/include/bsd. So I > added to my main source file: > > #ifdef BSD > #include > #endif > > #ifdef LINUX > #include > #endif > > And as I say, no problem on FBSD. > > To try it on Linux, I fired up my GitPod Ubuntu/Debian instance and > found that I had to install the libbsd0 and libbsd-dev packages first. > However, when I first compiled, GCC complained: > undefined reference to `readpassphrase' > Oops! I added `-l:libbsd.a` to the linker arguments and it compiles fine > under Linux now. > > ifeq ($(UNAME),FreeBSD) > CFLAGS +=3D -DBSD > else ifeq ($(UNAME),Linux) > CFLAGS +=3D -DLINUX > LDFLAGS +=3D -l:libbsd.a > endif > > Unfortunatly, the program segfaults when I run it! Works fine on FBSD. > Well, I've got something "constructive" to do today! > > Thanks again everyone, > > - Jonathan > ____________________________________________ > "Before Turing, things were done to numbers. > After Turing, numbers began doing things" > - George Dyson Assume you have a program to be compiled in different operating systems . Actually to maintain ONE make file for ALL involved operating systems may be very difficult not only for you but also for your users . Instead of trying to use one make file , the following approach may be more easy to manage ( This idea is not originally developed by me , but I have learned it from other people ) : For each different OS , define a directory with a make file specific to the OS . Since the make file is specific to the OS , if a user does not use that OS , make file will not cause any difficulty . If a change is made in one of the OS make files , it will not affect the other OS make files . If some parts are common to different OS make files , these parts may be stored into a separate directory and may be included into relevant make files . Use of such a division of make files may eliminate a large number of "if" conditional and sometimes conflicting statements required to be used in a single common file . Mehmet Erol Sanliturk --00000000000014cdd60610cfd285 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, Feb 7, 2024 at 10:10= =E2=80=AFPM Jonathan Adams <jfa= dams1963@proton.me> wrote:
On Tuesday, February 6th, 2024 at 10:38 PM, Greg 'gro= ggy' Lehey <gr= og@freebsd.org> wrote:

> However, I've put this through gmake, and it complains:
>
> $ gmake
> Makefile:7: extraneous text after 'ifeq' directive

Hi Greg, et al.,
=C2=A0 The above error was do to the line continuation backslashes. Install= ed gmake, took out the backslashes and, presto, it "just works". = On FBSD, that is.
=C2=A0 In my little project, I was using getpass(), but have changed to rea= dpassphrase(). Great, but on Linux that's in /usr/include/bsd. So I add= ed to my main source file:

#ifdef BSD
=C2=A0 =C2=A0 #include <readpassphrase.h>
#endif

#ifdef LINUX
=C2=A0 =C2=A0 #include <bsd/readpassphrase.h>
#endif

And as I say, no problem on FBSD.

=C2=A0 To try it on Linux, I fired up my GitPod Ubuntu/Debian instance and = found that I had to install the libbsd0 and libbsd-dev packages first. Howe= ver, when I first compiled, GCC complained:
undefined reference to `readpassphrase'
Oops! I added `-l:libbsd.a` to the linker arguments and it compiles fine un= der Linux now.

ifeq ($(UNAME),FreeBSD)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS +=3D -DBSD
else ifeq ($(UNAME),Linux)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 CFLAGS +=3D -DLINUX
=C2=A0 =C2=A0 =C2=A0 =C2=A0 LDFLAGS +=3D -l:libbsd.a
endif

=C2=A0 Unfortunatly, the program segfaults when I run it! Works fine on FBS= D. Well, I've got something "constructive" to do today!

Thanks again everyone,

-=C2=A0Jonathan
____________________________________________
"Before Turing, things were done to numbers.
After Turing, numbers began doing things"
- George Dyson


Assume you = have a program to be compiled in different operating systems .
Actua= lly to maintain=C2=A0 ONE make file for ALL involved operating systems may = be
very difficult not only for you but also for your users .
=
Instead of trying to use one make file , the following approach= may be more easy to manage
( This idea is not originally devel= oped by me , but I have learned it from other people ) :

<= div style=3D"font-family:monospace;font-size:large" class=3D"gmail_default"= >For each different OS , define a directory with a make file specific to th= e OS .
Since the make file is specific to the OS , if a user does no= t use that OS , make file
will not cause any difficulty .
=

If a change is made in one of the OS make files , it will not= affect the other OS make files .

If some parts are comm= on to different OS make files , these parts may be stored into a separate
directory and may be included into relevant make files .

<= /div>
Use of such a division of make files may eliminate a large number of= "if" conditional and sometimes conflicting
statements req= uired to be used in a single common file .


Mehmet Erol Sanliturk





=C2=A0









<= /div>


=C2=A0
--00000000000014cdd60610cfd285--